package com.maven.front.service.manageLogin;

import com.maven.front.aop.SysLog;
import com.maven.front.bean.SysFunction;
import com.maven.front.bean.SysLoginLog;
import com.maven.front.bean.SysRole;
import com.maven.front.bean.SysUser;
import com.maven.front.mapper.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 后台登陆
 * 用户增删改查
 */
@Service
public class SysLoginService {

        @Resource
        private SysUserMapper sysUserMapper;

        @Resource
        private SysLoginLogMapper sysLoginLogMapper;

        @Resource
        private SysRoleMapper sysRoleMapper;

        @Resource
        private SysFunctionMapper sysFunctionMapper;

        @Resource
        private SysLogMapper sysLogMapper;
        //登录查询
         public SysUser login(SysUser sysUser) {
             return this.sysUserMapper.login(sysUser);
         }


          //查询全部数据/模糊查询
         public List<SysUser> list(String keyWord){
             return this.sysUserMapper.select(keyWord);
         }
         //新增
          public int insert(SysUser sysUser){
             return this.sysUserMapper.insert(sysUser);
          }
          //删除
            public int delete(int id){
             return this.sysUserMapper.deleteByPrimaryKey(id);
            }
            //更新
            public  int update(SysUser sysUser){
             return this.sysUserMapper.updateByPrimaryKey(sysUser);
            }
            //修改密码
            public int updatePwd(SysUser sysUser){
             return this.sysUserMapper.updateByPrimaryKeySelective(sysUser);
            }

             //逻辑删除
            public int upPassword(Integer id){
              return this.sysUserMapper.upPassword(id);
            }

            //冻结
            public int updateStatus(SysUser sysUser){
             return this.sysUserMapper.updateStatus(sysUser);
            }

             //根据loginName查询个人信息
           public SysUser selectName(String name){
             return this.sysUserMapper.selectName(name);
           }
            //根据ID查询单挑数据
             public SysUser getById(int id){
                   return this.sysUserMapper.selectByPrimaryKey(id);
            }

            //查看日志
           public List<SysLoginLog> selectLogin(int id){

             return this.sysLoginLogMapper.selectByPrimaryKey(id);
           }
           //查询role表所有数据
            public List<SysRole> listAll(SysRole sysRole){

             return this.sysRoleMapper.select(sysRole);
            }

            //查询系统日志
            public List<SysLog> selectSyslog(){
             return this.sysLogMapper.selectSyslog();
            }
}
